package com.wtf.dsp.admin.interceptor;


import com.alibaba.ttl.TransmittableThreadLocal;

import com.wtf.dsp.admin.model.LoginUser;

/**
 * ClassName: AuthContextIntercepter
 * Description: 登录拦截器
 * date: 2020/12/3 9:39
 *
 * @author linhuanyou
 */
public class AuthContextHolder {

    private TransmittableThreadLocal<LoginUser> threadLocal = new TransmittableThreadLocal<LoginUser>();
    private static final AuthContextHolder instance = new AuthContextHolder();

    private AuthContextHolder() {
    }

    public static AuthContextHolder getInstance() {
        return instance;
    }

    public void setContext(LoginUser t) {
        this.threadLocal.set(t);
    }

    public LoginUser getContext() {
        return (LoginUser)this.threadLocal.get();
    }

    public void clear() {
        this.threadLocal.remove();
    }

}
